|
|
 |
|
|
|
|
' Set Form Property
frmNew.EmpID = lngEmpID
' Display New Instance of the Customer Form frmNew.Show
' Set Tag Property for Searching frmNew.Tag = lngEmpID End If
End If
End Sub |
|
|
|
|
|
|
|
|
This code dims a pointer to the frmEmployee form. It then grabs the employee ID from the ItemData() property of the list box and stores it in a local variable. Next, it passes that local variable to the FormFind() function, which returns a True value if it finds the Employee Information form already open for this particular employee ID. If it does not find this employee form, a False value is returned. In this case, it creates a new instance of the form and stores the employee ID in the EmpID property on the frmEmployee form instance. Next, it shows the Employee Information form. Finally, it stores the employee ID in the Tag property of the Employee Information form. This Tag property value is used to find the employee form in the Forms collection. This occurs in the FormFind() function shown here: |
|
|
|
 |
|
|
|
|
Private Function FormFind(lngEmpID As Long) As Boolean
Dim frmAny As Form
FormFind = False
For Each frmAny In Forms
If IsNumeric(frmAny.Tag) Then
If CInt(Val(frmAny.Tag)) = lngEmpID Then
frmAny.SetFocus
FormFind = True
End If
End If
Next frmAny
End Function |
|
|
|
|
|
|
|
|
The FormFind() function loops through the Forms collection using a For...Each loop. It checks the form reference each time through the loop to see whether the Tag property has a numeric value in it. If it does, the value in the Tag property is compared against the value passed to this function. If a match is found, the focus is set to that form and a True value is returned from the FormFind() function. |
|
|
|
|
|